﻿using System;
using System.Globalization;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ProjectBase.Core;
using ProjectBase.Mvc;

namespace $safeprojectname$.Core.Extensions
{
    [TestClass]
    public class ToDisplayTest : TestBase
    {
        [TestMethod]
        public void ObjectDateToDisplay()
        {
            string result;
            string formatG = "G";
            string formatd = "d";
            IFormatProvider fp = CultureInfo.GetCultureInfo("en");
            DateTime value = DateTime.Now;

            result = ((object)value).ToDisplay();
            Assert.IsTrue(result.Equals(value.ToString(formatG)));

            result = ((object)value).ToDisplay(formatd);
            Assert.IsTrue(result.Equals(value.ToString(formatd)));

            result = ((object)value).ToDisplay(formatd, fp);
            Assert.IsTrue(result.Equals(value.ToString(formatd, fp)));

            result = ((object)value).ToDisplay(formatProvider: fp);
            Assert.IsTrue(result.Equals(value.ToString(fp)));
        }
        [TestMethod]
        public void DateToDisplay()
        {
            string result;
            string formatG = "G";
            string formatd = "d";
            IFormatProvider fp = CultureInfo.GetCultureInfo("en");
            var value = DateTime.Now;

            result = value.ToDisplay();
            Assert.IsTrue(result.Equals(value.ToString(formatG)));

            result = value.ToDisplay(formatd);
            Assert.IsTrue(result.Equals(value.ToString(formatd)));

            result = value.ToDisplay(formatd, fp);
            Assert.IsTrue(result.Equals(value.ToString(formatd, fp)));

            result = value.ToDisplay(formatProvider: fp);
            Assert.IsTrue(result.Equals(value.ToString(fp)));
        }

        [TestMethod]
        public void IntToDisplay()
        {
            string result;

            string formatN0 = "N0";
            string formatN2 = "N2";
            IFormatProvider fp = CultureInfo.GetCultureInfo("en");

            var value = 12345;

            result = value.ToDisplay();
            Assert.IsTrue(result.Equals(value.ToString(formatN0)));

            result = value.ToDisplay(formatN2);
            Assert.IsTrue(result.Equals(value.ToString(formatN2)));

            result = value.ToDisplay(formatN2, fp);
            Assert.IsTrue(result.Equals(value.ToString(formatN2, fp)));

            result = value.ToDisplay(formatProvider: fp);
            Assert.IsTrue(result.Equals(value.ToString(fp)));
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        [TestInitialize]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize(); // Use TestInitialize to run code before running each test
        }

        [TestCleanup]
        public override void MyTestCleanup()
        {
            base.MyTestCleanup(); // Use TestCleanup to run code after each test has run
        }
        #endregion
    }
}
